package org.example.controller;

import org.apache.ibatis.annotations.Param;
import org.example.domain.Summary;
import org.example.service.impl.SummaryServiceImpl;
import org.example.untils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("summary")
public class SummaryController {

    @Autowired
    private SummaryServiceImpl summaryServiceImpl;

    @PostMapping("/addOneSummary")
    private Result addOneSummary(@RequestBody Summary summary){
        summaryServiceImpl.addOneSummary(summary);
        return new Result(200,"提交成功",null);
    }

    @GetMapping("/getSummariesByUserId")
    public Result getSummariesByUserId(@Param("userId") Integer userId,@Param("start") Integer start){
        Summary[] summaries=summaryServiceImpl.getSummariesByUserId(userId,start);
        return new Result(200,"获取成功",summaries);
    }

    @GetMapping("/getSummariesByActivityId")
    public Result getSummariesByActivityId(@Param("activityId") Integer activityId,@Param("start") Integer start){
        Summary[] summaries=summaryServiceImpl.getSummariesByActivityId(activityId,start);
        return new Result(200,"获取成功",summaries);
    }

    @GetMapping("/changeStatusById")
    public Result changeStatusById(@Param("id") Integer id){
        summaryServiceImpl.changeStatusById(id);
        return new Result(200,"录用成功",null);
    }
}
